﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace KYKJ.Monitor.APIs
{
    public delegate int DecodeFrameDataDelegate(IntPtr frameData, int size);

    /// <summary>
    /// 图像解码回调
    /// </summary>
    /// <param name="imageData">图像数据</param>
    /// <param name="dataSize">数据大小  --该参数暂时未使用</param>
    /// <param name="width">图像宽度</param>
    /// <param name="height">图像高度</param>
    /// <param name="step">图像像素步进</param>
    /// <param name="trackX">追踪中心x点</param>
    /// <param name="trackY">追踪中心y点</param>
    /// <param name="trackW">追踪宽度</param>
    /// <param name="trackH">追踪高度</param>
    /// <returns></returns>
    public delegate int TrackResultData(IntPtr imageData, int dataSize, int width, int height, int step, int trackX, int trackY, int trackW, int trackH);

    public class DllImport
    {
        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern int Init(IntPtr handle, int colorType);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void Stop(int session);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern int RealTimePlay(int session, string url);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern int RealTimePlayForCallBack(int session, string url, DecodeFrameDataDelegate decodeCallback);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void SetShowRectangle(int session, int fillType, int x, int y, int width, int height);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void StartRecord(int session);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void EndRecord(int session);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void Shot(int session);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void SetAutoTrackRecord(int session, int type);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void SetTrackRectangle(int session, int x, int y, int width, int height, TrackResultData trackResultData);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern int PlayLocal(int session, string file);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern int PlayLocalForCallBack(int session, string file, DecodeFrameDataDelegate decodeCallback);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void Play(int session);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void Pause(int session);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void ReversePlay(int session);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void SetPlaySpeed(int session, int speed);

        [DllImport("PlayerDll.dll", CharSet = CharSet.Ansi)]
        public static extern void Seek(int session, int type, long start);

    }
}
